﻿@{
	ViewBag.Title = Resources.MeetingApply + ConstValues.strDash + Resources.HuiTongCIS;
}
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%" style="margin-top:10px;margin-bottom:10px">
	<tr>
		<td class="b1">
			<div>
				<p><img src="~/images/icon_06.png" align="absmiddle" />&nbsp;@Resources.MeetingList<span>&nbsp;>>&nbsp;</span>@Resources.MeetingApply
			</div>
		</td>
	</tr>
</table>
<div class="box clearfix">
	<form id="frmDetail" method="post" enctype="multipart/form-data">
		@Html.AntiForgeryToken()
		<table width="100%" height="100%" id="tblDetail" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
			<tr>
				<td style="text-align: right;" class="w1 c1">@Resources.ConferenceName：</td>
				<td style="text-align: left;" class="w2 c2" colspan="3">
					<input id="txtConferenceName" name="ConferenceName" class="easyui-textbox" style="height:27px; width:900px;" data-options="required:true" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right;" class="w1 c3">@Resources.ConferenceNickName：</td>
				<td style="text-align: left;" class="w2 c4" colspan="3">
					<input id="txtConferenceNickName" name="ConferenceNickName" class="easyui-textbox" style="height:27px; width:900px;" data-options="required:true, validType:['length[1,20]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right; " class="w1 c1">@Resources.ConferenceDate：</td>
				<td style="text-align: left;" class="w2 c2">
					<input id="dateConferenceStartDate" name="ConferenceStartDate" class="easyui-datebox" style="height:27px; width:135px;" data-options="required:true,editable:false" />&nbsp;@Resources.To&nbsp;
					<input id="dateConferenceEndDate" name="ConferenceEndDate" class="easyui-datebox" style="height:27px; width:135px;" data-options="required:true,editable:false" />
				</td>
				<td style="text-align: right;" class="w1 c1">@Resources.OperateTime：</td>
				<td style="text-align: left;" class="w2 c2">
					<input id="txtOperateTime" name="OperateTime" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right;" class="w1 c3">@Resources.OperateLocation：</td>
				<td style="text-align: left;" class="w2 c4">
					<input id="txtOperateLocation" name="OperateLocation" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true, validType:['length[1,100]']" />
				</td>
				<td style="text-align: right;" class="w1 c3">@Resources.ConferenceAddress：</td>
				<td style="text-align: left;" class="w2 c4">
					<input id="txtConferenceAddress" name="ConferenceAddress" class="easyui-textbox" style="height:27px; width:300px;" data-options="validType:['length[1,100]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right;" class="w1 c1">@Resources.Sponsor：</td>
				<td style="text-align: left;" class="w2 c2" colspan="3">
					<input id="txtSponsor" name="Sponsor" class="easyui-textbox" style="height:27px; width:900px;" data-options="prompt:'@Resources.SponsorPrompt',validType:['length[1,200]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right;" class="w1 c3">@Resources.Organizer：</td>
				<td style="text-align: left;" class="w2 c4">
					<input id="txtOrganizer" name="Organizer" class="easyui-textbox" style="height:27px; width:300px;" data-options="validType:['length[1,100]']" />
				</td>
				<td style="text-align: right;" class="w1 c3">@Resources.CoOrganizer：</td>
				<td style="text-align: left;" class="w2 c4">
					<input id="txtCoOrganizer" name="CoOrganizer" class="easyui-textbox" style="height:27px; width:300px;" data-options="validType:['length[1,100]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right; " class="w1 c1">@Resources.ConferenceHomePageUrl：</td>
				<td style="text-align: left;" class="w2 c2" colspan="3">
					<input id="txtHomePageUrl" name="HomePageUrl" class="easyui-textbox" style="height:27px; width:900px;" data-options="prompt:'@Resources.Example http://www.htcis.net',validType:['length[1,100]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right; " class="w1 c3">@Resources.ConferenceSummary：</td>
				<td style="text-align: left;" class="w2 c4" colspan="3">
					<input id="txtSummary" name="Summary" class="easyui-textbox" style="height:50px; width:900px;" data-options="multiline:true, validType:['length[1,4000]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right;" class="w1 c1">@Resources.Contact：</td>
				<td style="text-align: left;" class="w2 c2">
					<input id="txtContact" name="Contact" class="easyui-textbox" style="height:27px; width:300px;" data-options="prompt:'@Resources.ContactPrompt',required:true, validType:['length[1,100]']" />
				</td>
				<td style="text-align: right;" class="w1 c1">@Resources.ContactPhone：</td>
				<td style="text-align: left;" class="w2 c2">
					<input id="txtContactPhone" name="ContactPhone" class="easyui-textbox" style="height:27px; width:300px;" data-options="prompt:'@Resources.ContactPrompt',required:true, validType:['length[1,100]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right;" class="w1 c3">@Resources.ContactMail：</td>
				<td style="text-align: left;" class="w2 c4" colspan="3">
					<input id="txtContactMail" name="ContactMail" class="easyui-textbox" style="height:27px; width:900px;" data-options="prompt:'@Resources.ContactPrompt',required:true, validType:['length[1,100]']" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right; " class="w1 c1">@Resources.PicForPC：</td>
				<td style="text-align: left;" class="w2 c2">
					<input id="picForPC" name="PicForPCFile" class="easyui-filebox" style="height:27px; width:200px;" data-options="prompt:'@Resources.UploadPicForPC', buttonText:'@Resources.Upload', accept: 'image/jpeg,image/png,image/gif'" />&nbsp;160*90
					<input type="hidden" id="hidPicForPC" name="PicForPCFilePath" />
					<a href="javascript:void(0)" class="easyui-linkbutton" onclick='$("#picForPC").filebox("clear"); $("#hidPicForPC").val("");'>@Resources.Clear</a>
				</td>
				<td style="text-align: right; " class="w1 c1">@Resources.PicForMobile：</td>
				<td style="text-align: left;" class="w2 c2">
					<input id="picForMobile" name="PicForMobileFile" class="easyui-filebox" style="height:27px; width:200px;" data-options="prompt:'@Resources.UploadPicForPC', buttonText:'@Resources.Upload', accept: 'image/jpeg,image/png,image/gif'" />&nbsp;160*90
					<input type="hidden" id="hidPicForMobile" name="PicForMobileFilePath" />
					<a href="javascript:void(0)" class="easyui-linkbutton" onclick='$("#picForMobile").filebox("clear"); $("#hidPicForMobile").val("");'>@Resources.Clear</a>
				</td>
			</tr>
			<tr>
				<td style="text-align: right; " class="w1 c3">@Resources.MetaKeywords：</td>
				<td style="text-align: left;" class="w2 c4" colspan="3">
					<input id="txtKeywords" name="Keywords" class="easyui-textbox" style="height:27px; width:900px;" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right; " class="w1 c1">@Resources.MetaDescription：</td>
				<td style="text-align: left;" class="w2 c2" colspan="3">
					<input id="txtDescription" name="Description" class="easyui-textbox" style="height:27px; width:900px;" />
				</td>
			</tr>
			<tr>
				<td style="text-align: right; " class="w1 c3">@Resources.Remark：</td>
				<td style="text-align: left;" class="w2 c4" colspan="3">
					<input id="txtRemark" name="Remark" class="easyui-textbox" style="height:50px; width:900px;" data-options="multiline:true, validType:['length[1,1000]']" />
				</td>
			</tr>
		</table>
	</form>
	<div class="btnDiv">
		<input type="button" id="saveBtn" class="gbtn" onclick="saveData();" value=@Resources.Submit  />&nbsp;&nbsp;
		<input type="button" class="rbtn" onclick="back();" value=@Resources.Cancel />&nbsp;&nbsp;
	</div>
</div>
@section Scripts {
	<script>
		$(function () {
			var language = "@((User as ICISPrincipal).Language)";
			if (language == "@ConstValues.Language.Cn") {
				CKEDITOR.config.language = "zh-cn";
			} else {
				CKEDITOR.config.language = "en";
			}
		});

		function back() {
			window.location.href = document.referrer;
		}

		function saveData() {
			var isValid = $("#frmDetail").form("validate");

			if (isValid) {
				var picForPC = $("#picForPC").filebox("getText");
				if (picForPC != "" && !/\.(gif|jpg|jpeg|png|GIF|JPG|PNG|JPEG)$/.test(picForPC)) {
					common.showError("@Resources.MsgImgType");
					return;
				}
				var picForMobile = $("#picForMobile").filebox("getText");
				if (picForMobile != "" && !/\.(gif|jpg|jpeg|png|GIF|JPG|PNG|JPEG)$/.test(picForMobile)) {
					common.showError("@Resources.MsgImgType");
					return;
				}

				var ConferenceStartDate = $.fn.datebox.defaults.parser($("#dateConferenceStartDate").datebox("getValue"));
				var ConferenceEndDate = $.fn.datebox.defaults.parser($("#dateConferenceEndDate").datebox("getValue"));
				if (ConferenceStartDate > ConferenceEndDate) {
					common.showError("@Resources.MsgConferenceDateInputError");
					return;
				}

				if (!/^[A-Za-z0-9]+$/.test($("#txtConferenceNickName").textbox("getValue"))) {
					common.showError("@Resources.MsgConferenceNickNameInputError");
					return;
				}

				$.messager.confirm("@Resources.Submit", "@Resources.CfmSave", function (r) {
					if (r) {
						$("#frmDetail").form({
							iframe: false,
							success: function (data) { }
						});

						var loading = layer.load(0, {
							shade: [0.4, "#fff"]
						});

						$("#frmDetail").form("submit", {
							url: "@Url.Action(nameof(MeetingApplyController.Apply), nameof(MeetingApplyController).GetControllerName())",
							onSubmit: function (param) {
								param.random = Math.random();
							},
							success: function (data) {
								layer.close(loading);
								data = JSON.parse(data);
								if (data.result == "@ConstValues.AjaxFailResult") {
									common.showError(data.message);
								} else {
									common.showSuccess(data.message);
									setTimeout(function () {
										back();
									}, 2000);
								}
							}
						});

						$.post("@Url.Action(nameof(MeetingApplyController.Apply),
								nameof(MeetingApplyController).GetControllerName())",
							$("#frmDetail").serialize(),
							function (data, textStatus, jqXHR) {
								if (data.result == "@ConstValues.AjaxFailResult") {
									common.showError(data.message);
									layer.close(loading);
								} else {
									common.showSuccess(data.message);
									setTimeout(function () {
										back();
									}, 2000);
								}
							}
						);
					}
				});
			}
		}
	</script>
}